﻿using UnityEngine;
using System.Collections;

/**
 * 如何创建和使用委托在脚本中提供复杂的动态功能
 */
public class DelegateScript : MonoBehaviour 
{       
    delegate void MyDelegate(int num);
    MyDelegate myDelegate;


    void Start () 
    {
        myDelegate = PrintNum;
        myDelegate(50);

        myDelegate = DoubleNum;
        myDelegate(50);
    }

    void PrintNum(int num)
    {
        print ("Print Num: " + num);
    }

    void DoubleNum(int num)
    {
        print ("Double Num: " + num * 2);
    }
}